<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<style>
    *{
        box-sizing: border-box;
        padding: 0;
        margin: 0;
    }

    body{
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100vh;

    }

    .nav{
        width: 800px;
        height: 70px;
        position: relative;
        border:1px solid red;
        box-shadow: 0 5px 20px rgba(0,0,0,0.5);
        border-radius: 10px;
        display: flex;
    }

    .nav ul {
        display: flex;
        width: 100%;
    }


    .nav ul li {
        width: 100%;
        text-align: center;
        flex: 1;
        list-style: none;
    }

    .nav ul li a{
        color: rgb(70,100,100);
        display: block;
        width: 100%;
        height: 100%;
        line-height: 70px;
        text-decoration: none;
        /*font: 100 30px;*/
    }

    /*.nav ul li:nth-child(1)*/

    .nav ul .nav-box{
        position: absolute;
        bottom: 0;
        left: 0;
        height: 10px;
        width: calc(100% / 6);
        background-color: yellow;
        transition: all 0.5s;

    }


    /*  ~通用的兄弟选择器 */
    .nav ul li:nth-child(1):hover~.nav-box{
        left: calc((100% / 6)*0);
        background: lightcoral;
    }


    .nav ul li:nth-child(2):hover~.nav-box{
        left: calc((100% / 6)*1);
        background: lightgoldenrodyellow;
    }
    .nav ul li:nth-child(3):hover~.nav-box{
        left: calc((100% / 6)*2);
        background: orange;
    }

    .nav ul li:nth-child(4):hover~.nav-box{
        left: calc((100% / 6)*3);
        background: lightseagreen;
    }

    .nav ul li:nth-child(5):hover~.nav-box{
        left: calc((100% / 6)*4);
        background: lightgoldenrodyellow;
    }


    .nav ul li:nth-child(6):hover~.nav-box{
        left: calc((100% / 6)*5);
    }




</style>
<div class="nav">
    <ul >
        <li><a href="#">html</a></li>
        <li><a href="#">css</a></li>
        <li><a href="#">js</a></li>
        <li><a href="#">java</a></li>
        <li><a href="#">html</a></li>
        <li><a href="#">html</a></li>

        <div class="nav-box">

        </div>
    </ul>
</div>


<script>


</script>
</body>
</html>
